package org.xbill.DNS.utils;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class base16
{
  private static final String Base16 = "0123456789ABCDEF";

  public static byte[] fromString(String paramString)
  {
    byte[] arrayOfByte2;
    DataOutputStream localDataOutputStream;
    int j;
    byte[] arrayOfByte3;
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    byte[] arrayOfByte1 = paramString.getBytes();
    int i = 0;
    if (i >= arrayOfByte1.length)
    {
      arrayOfByte2 = localByteArrayOutputStream.toByteArray();
      if (arrayOfByte2.length % 2 == 0)
        break label64;
      arrayOfByte3 = null;
    }
    while (true)
    {
      while (true)
      {
        return arrayOfByte3;
        if (!(Character.isWhitespace((char)arrayOfByte1[i])))
          localByteArrayOutputStream.write(arrayOfByte1[i]);
        ++i;
      }
      label64: localByteArrayOutputStream.reset();
      localDataOutputStream = new DataOutputStream(localByteArrayOutputStream);
      j = 0;
      if (j < arrayOfByte2.length)
        break;
      arrayOfByte3 = localByteArrayOutputStream.toByteArray();
    }
    int k = (byte)"0123456789ABCDEF".indexOf(Character.toUpperCase((char)arrayOfByte2[j]));
    int l = (byte)"0123456789ABCDEF".indexOf(Character.toUpperCase((char)arrayOfByte2[(j + 1)])) + (k << 4);
    try
    {
      localDataOutputStream.writeByte(l);
      label146: j += 2;
    }
    catch (IOException localIOException)
    {
      break label146:
    }
  }

  public static String toString(byte[] paramArrayOfByte)
  {
    ByteArrayOutputStream localByteArrayOutputStream = new ByteArrayOutputStream();
    int i = 0;
    while (true)
    {
      if (i >= paramArrayOfByte.length)
        return new String(localByteArrayOutputStream.toByteArray());
      int j = (short)(0xFF & paramArrayOfByte[i]);
      int k = (byte)(j >> 4);
      int l = (byte)(j & 0xF);
      localByteArrayOutputStream.write("0123456789ABCDEF".charAt(k));
      localByteArrayOutputStream.write("0123456789ABCDEF".charAt(l));
      ++i;
    }
  }
}